package com.wh.hotel.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wh.common.annotation.ResultLog;
import com.wh.common.enums.MethodTypeEnum;
import com.wh.hotel.constants.CommonConstant;
import com.wh.hotel.mapper.HotelRoomTypeMapper;
import com.wh.hotel.model.HotelRoomType;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wenhao
 */
@Component
public class HotelRoomTypeDao {

    @Resource
    private HotelRoomTypeMapper hotelRoomTypeMapper;

    @ResultLog(name = "HotelRoomTypeDao.selectById", methodType = MethodTypeEnum.DB, printResult = false)
    public HotelRoomType selectById(Long roomTypeId) {
        return hotelRoomTypeMapper.selectById(roomTypeId);
    }
    @ResultLog(name = "HotelRoomTypeDao.insert", methodType = MethodTypeEnum.DB)
    public boolean insert(HotelRoomType hotelRoomType) {
        return hotelRoomTypeMapper.insert(hotelRoomType) >= CommonConstant.SUCCESS_DB;
    }

    @ResultLog(name = "HotelRoomTypeDao.update", methodType = MethodTypeEnum.DB)
    public boolean update(HotelRoomType hotelRoomType) {
        return hotelRoomTypeMapper.updateById(hotelRoomType) >= CommonConstant.SUCCESS_DB;
    }

    @ResultLog(name = "HotelRoomTypeDao.selectByRuleId", methodType = MethodTypeEnum.DB, printResult = false)
    public List<HotelRoomType> selectByRuleId(Long bookRuleId) {
        LambdaQueryWrapper<HotelRoomType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HotelRoomType::getBookRuleId, bookRuleId);
        return hotelRoomTypeMapper.selectList(queryWrapper);
    }

    @ResultLog(name = "HotelRoomTypeDao.selectBatchById", methodType = MethodTypeEnum.DB, printResult = false)
    public List<HotelRoomType> selectBatchById(List<Long> idList) {
        return hotelRoomTypeMapper.selectBatchIds(idList);
    }

}
